package cn.legend.travel.destination.main.startup;

import cn.legend.travel.destination.main.service.IDistrictService;
import cn.legend.travel.destination.main.service.IGuideService;
import cn.legend.travel.destination.main.service.ISceneryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * 省市区数据的缓存预热类
 *
 * @author java@tedu.cn
 * @version 1.0
 **/
@Slf4j
@Component
public class DistrictRunner implements ApplicationRunner {

    @Autowired
    private IDistrictService districtService;
    @Autowired
    private ISceneryService sceneryService;
    @Autowired
    private IGuideService guideService;

    public DistrictRunner() {
        log.debug("创建ApplicationRunner对象：DistrictRunner");
    }

    @Override
    public void run(ApplicationArguments args) {
        log.debug("开始处理【省市区数据缓存预热】，无参数");
        districtService.rebuildCache();
        districtService.elasticsearch();
        sceneryService.rebuildScenery();
        sceneryService.elasticsearchScenery();
        guideService.guideElasticsearch();
    }

}
